package com.qk.management.handler;

import com.qk.common.Result;
import com.qk.common.enums.Code;
import com.qk.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author diva
 * @date 2025/10/7 9:26
 * @ProjectName
 */
@Slf4j
@RestControllerAdvice
public class MyGlobalExceptionHandle {
    //@ExceptionHandler(value = Exception.class)
    public Result handleException(Exception e){
        log.error("服务器异常：{}",e.getMessage());
        return Result.error("网络异常，请稍后重试");
    }
    @ExceptionHandler(value = CommonException.class)
    public Result handleException(CommonException e){
        return Result.error(e.getMessage());
    }

}
